package com.cskaoyan.service.wx;

import com.cskaoyan.Utils.MyUtils;
import com.cskaoyan.mapper.mallmapper.OrderMapper;
import com.cskaoyan.vo.wx.WxUserIndexVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author hsp
 * @date 2021/5/12 21:26
 */
@Service
public class WxUserIndexServiceImpl implements WxUserIndexService {

    @Autowired
    OrderMapper orderMapper;
    @Override
    public WxUserIndexVo getUserIndex() {
        Integer userId = MyUtils.getUserId();
        //unrecv -->未收货-->已发货-->301
        //uncomment-->未评价-->用户收货-->401
        //unpaid-->未付款-->101
        //unship-->未发货-->已付款-->201

       Integer unrecv =  orderMapper.selectUnrecvCountByUserId(userId);
       Integer uncomment = orderMapper.selectUncommentCountByUserId(userId);
       Integer unpaid = orderMapper.selectUnpaidCountByUserId(userId);
       Integer unship = orderMapper.selectUnshipCountByUserId(userId);

        WxUserIndexVo.OrderBean orderBean = new WxUserIndexVo.OrderBean();
        orderBean.setUnrecv(unrecv);
        orderBean.setUncomment(uncomment);
        orderBean.setUnpaid(unpaid);
        orderBean.setUnship(unship);
        WxUserIndexVo wxUserIndexVo = new WxUserIndexVo();
        wxUserIndexVo.setOrder(orderBean);
        return wxUserIndexVo;
    }
}
